global !p

from builtin import choose_next
from mdtex.scopes import math

dots = ['', 'c', 'v', 'd']
infties = ['', '-', '+']
nornots = ['', 'n']

endglobal

################################################################
#                                                              #
#                           Symbols                            #
#                                                              #
################################################################

context "math()"
snippet ... "省略号 Ellipsis" Ai
\dots
endsnippet

context "math()"
snippet -. "中心点 Center Dot" Ai
\cdot 
endsnippet

context "math()"
snippet o- "Circ" Aw
\circ 
endsnippet

context "math()"
snippet "\\((?:c|v|d)?)dots(\s?)" "省略号转换 Ellipsis Transformation" r
\\`!p snip.rv = choose_next(match.group(1), dots, 4) + 'dots' + match.group(2)`
endsnippet

context "math()"
snippet ooo "无穷大 Infinity" Aw
\infty 
endsnippet

context "math()"
snippet nabla "算子 Nabla" Aw
\nabla 
endsnippet

context "math()"
snippet "((?:\+|-)?)\\infty(\s?)" "无穷大转换 Infinity Transformation" r
`!p snip.rv = choose_next(match.group(1), infties, 3) + '\\infty' + match.group(2)`
endsnippet

context "math()"
snippet ang "角 Angle" w
\angle 
endsnippet

context "math()"
snippet tri "三角形 Triangle" w
\triangle 
endsnippet

context "math()"
snippet deg "度 Degree" w
\degree 
endsnippet

context "math()"
snippet par "平行 Parallel" w
\par 
endsnippet

context "math()"
snippet perp "垂直 Perpendicular" w
\perp 
endsnippet

context "math()"
snippet "\b(ssd|hsd)" "摄氏度/华氏度 Celsius/Fahrenheit" Ar
\\`!p snip.rv = match.group(1)`
endsnippet

priority 1
context "math()"
snippet "\\(n?)(par\s?)" "平行转换 Parallel Transformation" r
\\`!p snip.rv = choose_next(match.group(1), nornots, 2) + match.group(2)`
endsnippet
